<html>
<head><meta charset="utf-8"><title>type-based smart completions · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/type-based.20smart.20completions.html">type-based smart completions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="240082821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/type-based%20smart%20completions/near/240082821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Chin (eminence) <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/type-based.20smart.20completions.html#240082821">(May 24 2021 at 17:24)</a>:</h4>
<p>I wonder if it would be possible to use types as hints about how to order/prioritize completions.  For example, If I write:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">max</span>: <span class="kt">usize</span> <span class="o">=</span><span class="w"> </span><span class="n">my_vec</span><span class="p">.</span><span class="o">&lt;|&gt;</span><span class="w"></span>
</code></pre></div>
<p>an initiate completions on my_vec, it would be Super Cool if RA could prioritize things that return a usize</p>



<a name="240083266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/type-based%20smart%20completions/near/240083266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/type-based.20smart.20completions.html#240083266">(May 24 2021 at 17:28)</a>:</h4>
<p>We have that to some extent already</p>



<a name="240083330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/type-based%20smart%20completions/near/240083330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/type-based.20smart.20completions.html#240083330">(May 24 2021 at 17:28)</a>:</h4>
<p>Maybe not everywhere though, not totally sure</p>



<a name="240083648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/type-based%20smart%20completions/near/240083648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/type-based.20smart.20completions.html#240083648">(May 24 2021 at 17:31)</a>:</h4>
<p>We mostly use it to show qualified enum variants I think</p>



<a name="240083915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/type-based%20smart%20completions/near/240083915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Chin (eminence) <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/type-based.20smart.20completions.html#240083915">(May 24 2021 at 17:33)</a>:</h4>
<p>yeah, it works pretty well there i think</p>



<a name="240089112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/type-based%20smart%20completions/near/240089112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/type-based.20smart.20completions.html#240089112">(May 24 2021 at 18:11)</a>:</h4>
<p>don't we also use it to prioritize completions? maybe not for method return types</p>



<a name="240089928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/type-based%20smart%20completions/near/240089928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Chin (eminence) <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/type-based.20smart.20completions.html#240089928">(May 24 2021 at 18:17)</a>:</h4>
<p>ahh, yes i do see some prioritization based on types.  for example, completing within <code>my_vec.push()</code> will prioritize types that can actually fit in the Vec</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>